package com.example.server.web.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 结果返回类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "结果返回类对象", description = "")
public class RespBean {
    @ApiModelProperty("状态码")
    private long code;
    @ApiModelProperty("结果消息")
    private String message;
    @ApiModelProperty("返回结果数据")
    private Object data;

    /**
     * 成功返回结果
     * */
    public static RespBean success(String message){
        return  new RespBean(200,message,null);
    }

    /**
     * 成功返回结果
     * */
    public static RespBean success(String message, Object data){
        return  new RespBean(200,message,data);
    }

    /**
     * 失败返回结果
     * */
    public static RespBean error(String message){
        return new RespBean(500,message,null);
    }

    /**
     * 失败返回结果
     * */
    public static RespBean error(String message, Object data){
        return new RespBean(500,message,data);
    }

    /**
     * 失败返回结果
     * */
    public static RespBean error(long code,String message, Object data){
        return new RespBean(code,message,data);
    }
}
